From 3fc0715d33ccea567526242d2247576930db4a7c Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Mon, 5 Feb 2018 17:04:11 +0100 Subject: [PATCH] Make the default behaviour of `cargo build` match the documentation cargo build --help says: --all-targets Build all targets (lib and bin targets by default) but the old default behaviour was actually doing --all-targets. This meant that --avoid-dev-deps was only effectively if one gave --lib --bins explicitly. With this commit, `cargo build --avoid-dev-deps` with no other flags, will build lib and bins and avoid installing dev-dependencies. --- src/cargo/ops/cargo_compile.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index bf905c3af..d7c08c9c4 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -421,7 +421,7 @@ impl<'a> CompileFilter<'a> { pub fn need_dev_deps(&self) -> bool { match *self { - CompileFilter::Default { .. } => true, + CompileFilter::Default { .. } => false, CompileFilter::Only { examples, tests, benches, .. } => examples.is_specific() || tests.is_specific() || benches.is_specific() } @@ -429,7 +429,11 @@ impl<'a> CompileFilter<'a> { pub fn matches(&self, target: &Target) -> bool { match *self { - CompileFilter::Default { .. } => true, + CompileFilter::Default { .. } => match *target.kind() { + TargetKind::Bin => true, + TargetKind::Lib(..) => true, + _ => false, + }, CompileFilter::Only { lib, bins, examples, tests, benches, .. } => { let rule = match *target.kind() { TargetKind::Bin => bins, -- 2.30.2